const BASE_URL = 'http://localhost:3000';

const request = (url, options = {}) => {
  console.log('发起请求:', `${BASE_URL}${url}`, options);
  
  return new Promise((resolve, reject) => {
    wx.request({
      url: `${BASE_URL}${url}`,
      ...options,
      success: (res) => {
        console.log('请求成功:', res);
        resolve(res.data);
      },
      fail: (err) => {
        console.error('请求失败:', err);
        reject(err);
      }
    });
  });
};

module.exports = request;